#pragma once
#include "HwndHost.h"
#include <CommCtrl.h>

namespace GUIToolkit
{
	class ToolTip
		: public HwndHost
	{
	private:
		TOOLINFO toolTip;

	public:
		ToolTip( HWND parent );

		virtual void SetVisible(bool value)
		{
			this->SendMessage(TTM_TRACKACTIVATE, value, (LPARAM) &toolTip);
		}

		virtual void SetPosition( float x, float y )
		{
			this->SendMessage(TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG((long)x, (long)y)); 
		}

		virtual void SetText(wstring text)
		{
			toolTip.lpszText = const_cast<wchar_t*>(text.c_str());
			this->SendMessage(TTM_SETTOOLINFO, 0, (LPARAM) &toolTip);
		}

		bool IsAlwaysTip() const
		{
			return this->GetWindowStyle() & TTS_ALWAYSTIP;
		}

		void SetAlwaysTip(bool value)
		{
			this->SetWindowStyle(this->GetWindowStyle() | (value ? TTS_ALWAYSTIP : !TTS_ALWAYSTIP));
		}

		bool IsBalloon() const
		{
			return this->GetWindowStyle() & TTS_BALLOON;
		}

		void SetBalloon(bool value)
		{
			this->SetWindowStyle(this->GetWindowStyle() | (value ? TTS_BALLOON : !TTS_BALLOON));
		}

		bool IsPrefix() const
		{
			return !(this->GetWindowStyle() & TTS_NOPREFIX);
		}

		void SetPrefix(bool value)
		{
			this->SetWindowStyle(this->GetWindowStyle() | (value ? !TTS_NOPREFIX : TTS_NOPREFIX));
		}

		virtual ~ToolTip()
		{
			this->SendMessage(TTM_DELTOOL, 0, 0);
		}
	};
}